package com.example.administrator.yunniuusedcar.util;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;

import com.example.administrator.common.utils.LogUtil;
import com.example.administrator.common.utils.SharedPreUtil;
import com.example.administrator.yunniuusedcar.R;

/**
 * Created by Administrator on 2018/1/4.
 */

public class popupwindow {

//        public PopupWindow mPopupWindow;
//    private View mMPpwindow;
//
//    public void onClick(View v) {
//         //   LayoutInflater layoutInflater = LayoutInflater.from(this);
//        mMPpwindow = layoutInflater.inflate(R.layout.item_populwindow, null);
//            if (mPopupWindow == null) {
//                //创建一个弹出窗口对象
//                mPopupWindow = new PopupWindow();
//            }
//            mPopupWindow.setContentView(mMPpwindow);//设置文本内容
//            mPopupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);//设置宽度
//            mPopupWindow.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);//设置高度
////        mPopupWindow.setHeight(Global.dp2px(400));//设置高度
//            mPopupWindow.setFocusable(false);//设置焦点
//            mPopupWindow.setOutsideTouchable(false);//设置外界可点击
//            mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00ffffff")));//解决安卓7.0以下的BUG
//            //设置一个与抛锚的偏移量
//            mPopupWindow.showAtLocation(mMPpwindow, Gravity.BOTTOM, 0, 0);
//           // initppwindow();
//        }

//        private void initppwindow() {
//            Button disagree = mMPpwindow.findViewById(R.id.ppw_disagree);
//            Button agreement = mMPpwindow.findViewById(R.id.ppw_agreement);
//            disagree.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    ToastUtil.showToast(getBaseContext(), "我知道了");
//                    mPopupWindow.dismiss();
//                }
//            });
//            agreement.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    SharedPreUtil.saveString(getBaseContext(), "username", mUsername);
//                    SharedPreUtil.saveString(getBaseContext(), "password", mPassword);
//                    LogUtil.e("---", mUsername);
//                    LogUtil.e("---", mPassword);
//                    ToastUtil.showToast(getBaseContext(), "现在登录");
//                    finish();
//                }
//            });
//        }

    /**
     *
     * int yourChoice;
     private void showSingleChoiceDialog(){
     final String[] items = { "我是1","我是2","我是3","我是4" };
     yourChoice = -1;
     AlertDialog.Builder singleChoiceDialog =
     new AlertDialog.Builder(MainActivity.this);
     singleChoiceDialog.setTitle("我是一个单选Dialog");
     // 第二个参数是默认选项，此处设置为0
     singleChoiceDialog.setSingleChoiceItems(items, 0,
     new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    yourChoice = which;
    }
    });
     singleChoiceDialog.setPositiveButton("确定",
     new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    if (yourChoice != -1) {
    Toast.makeText(MainActivity.this,
    "你选择了" + items[yourChoice],
    Toast.LENGTH_SHORT).show();
    }
    }
    });
     singleChoiceDialog.show();

     */
}
